<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="p" uri="/WEB-INF/tld/page.tld" %>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>营业统计</title>
<jsp:include page="/header.jsp"></jsp:include>
<link href="${basePath }/css/ui.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
	$(function() {
		
		$("#order_date1").datepicker({dateFormat: 'yy-mm-dd'});
		$("#order_date2").datepicker({dateFormat: 'yy-mm-dd'});
	});
	
	function query() {
		var start = $("#order_date1").val();
		start.replaceAll("-", "/");
		var end = $("#order_date2").val();
		end.replaceAll("-", "/");
		var date1 = new Date(start);
		var date2 = new Date(end);
		if(date1.getTime()>date2.getTime()) $.jqalert("起始日期不能大于截止日期！！");
		else $("#scat_order_form").submit();
	}
	
	function turnpage(pageNo) {
		$("#scat_order_form").children().first().val(pageNo);
		query();
	}
	
	function reset() {
		$("#scat_order_form").find("input").val("");
		$("#scat_order_form").find("select").val("");
	}
</script>

</head>
<body>
    <div class="main">
     	<div class="cont">
		    <h2 class="title">查询条件：</h2>
		    <div class="ui_sel clearfix">
		    <form id="scat_order_form" method="post" action="${basePath }/summary/index.htm">
		    	<input type="hidden" name="pageNo">
		    	<div class="label_box fl">
		            <span class="sel_label fl">门店名称：</span>
		            <select name="store_name">
		                <option value="">--全部--</option>
		                <c:forEach items="${stores }" var="store">
		                	<option value="${store.store_name }"
		                	<c:if test="${store.store_name eq query.store_name }"> selected="selected"</c:if>
		                	>${store.store_name }</option>
		                </c:forEach>
		            </select>
		        </div>
		        <div class="label_box fl">
		            <span class="sel_label fl">时间段：</span>
		            <input id="order_date1" type="text" readonly="readonly" name="order_date1" value="${query.order_date1 }">
		        </div>
		        <div class="label_box fl">
		            <span class="sel_label fl">至</span>
		            <input id="order_date2" type="text" readonly="readonly" name="order_date2" value="${query.order_date2 }">
		        </div>
		        <div class="label_box fl">
		            <span class="sel_label fl">商品名称：</span>
		            <input type="text" class="text_input fl" name="product_name" value="${query.product_name }">
		        </div>
		        <div class="label_box fl">
		            <span class="sel_label fl">年份：</span>
		            <input type="text" class="text_input fl" name="productionyear" value="${query.productionyear }">
		        </div>
		        <div class="label_box fl">
		            <span class="sel_label fl">业务类型：</span>
		            <select name="type">
		                <option value="">--全部--</option>
		                <c:forEach items="${tradeTypes }" var="type">
		                	<option value="${type.code }"
		                	<c:if test="${type.code eq query.type }"> selected="selected"</c:if>
		                	>${type.desc }</option>
		                </c:forEach>
		            </select>
		        </div>
		        
		        <a href="javascript:;" class="green_btn btn fl" onclick="query();">查询</a>
		        <a href="javascript:;" class="yellow_btn btn fl" onclick="reset();">清空</a>
		    </div>
		    <div class="ui">
		        <table class="table_list">
		            <tr class="">
		              <th class="">序号</th>
		              <th>交易号</th>
		              <th>交易类型</th>
		              <th class="">交易日期</th>
		              <th class="">品名</th>
		              <th class="">二维码</th>
		              <th class="">年份</th>
		              <th class="">批次</th>
		              <th class="">类型</th>
		              <th class="">价格（元）</th>
		              <th class="">折扣</th>
		              <th class="">折后价</th>
		              <th class="">重量单位</th>
		              <th class="">重量</th>
		              <th class="">单价（元/克）</th>
		              <th class="">小计（元）</th>
		            </tr>
		            <c:forEach items="${orders }" var="order" varStatus="status">
		            <tr class="">
		              <td class="">${status.index+1 }</td>
		              <td class="">${order.order_no }</td>
		              <td class="">${order.type_display }</td>
		              <td class="">${order.order_date_display }</td>
		              <td class="">${order.product_name }</td>
		              <td class="">${order.qrcode_id }</td>
		              <td class="">${order.productionyear }</td>
		              <td class="">${order.batch }</td>
		              <td class="">${order.unit}</td>
		              <td class="">${order.org_price }</td>
		              <td class="">${order.discount }</td>
		              <td class="">${order.now_price }</td>
		              <td class="">--</td>
		              <td class="">--</td>
		              <td class="">--</td>
		              <td class="">--</td>
		            </tr>
		            </c:forEach>
		            <tr class="">
		              <td class="">合计</td>
		              <td class=""></td>
		              <td class=""></td>
		              <td class=""></td>
		              <td class=""></td>
		              <td class=""></td>
		              <td class=""></td>
		              <td class=""></td>
		              <td class=""></td>
		              <td class="">${sum }</td>
		              <td class=""></td>
		              <td class="">${sum2 }</td>
		              <td class=""></td>
		              <td class=""></td>
		              <td class=""></td>
		              <td class="">--</td>
		            </tr>
		        </table>
		    </div>
		</div>
		<p:page map="${page }"></p:page>
</body>
</html>